import React, { Component } from 'react'
import { setTaroPageHeight } from '@UTILS/common'

export default function withWebSetRouteHeight(WrappedPage) {
  class WrappedComponent extends Component {
    setTaroPageHeight = setTaroPageHeight

    componentDidMount() {
      this.setTaroPageHeight('unset')
    }

    componentWillUnmount() {
      this.setTaroPageHeight()
    }

    render() {
      return (
        <>
          <WrappedPage
            {...this.props}
            setTaroPageHeight={this.setTaroPageHeight}
          />
        </>
      )
    }
  }
  return WrappedComponent
}
